package com.qadev.appergodic.base;

import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;

import java.io.File;
import java.net.URL;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;

/**
 * Created by wjp on 2019/8/7.
 */
public class Base {
    public static AndroidDriver driver;
    @BeforeSuite
    public void setUp() throws Exception {
        ArrayList<String> listFileName = new ArrayList<String>();
//        getAllFileName("D:\\zk\\V3.2", listFileName);
//        String name1 = listFileName.get(0);
        String name2 = "houbank_v3.14.0_201906241_debug(20190624142130).apk";
        File classpathRoot = new File("C:\\Users\\wjp\\Downloads\\");
//        File appDir = new File(classpathRoot, "V3.2");
        File app = new File(classpathRoot, name2);
        System.out.println(app);
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("deviceName", "NBWCJN7S99999999");//自动化引擎  NBWCJN7S99999999  WTKDU16704009107

        capabilities.setCapability("platformName", "Android");                    //手机os
        capabilities.setCapability("platformVersion", "5.1");                    //真机的Android版本
        capabilities.setCapability("newCommandTimeout", 180);                     //设置Appim超时时间
        capabilities.setCapability("app", app.getAbsolutePath());
        capabilities.setCapability("appPackage", "com.houbank.houbankfinance");
        capabilities.setCapability("appActivity", "com.houbank.houbankfinance.ui.FirstWelcomeActivity");
//        capabilities.setCapability("appPackage", "com.vmall.client");          //要启动的应用
//        capabilities.setCapability("appActivity","com.vmall.client.activity.VmallWapActivity");  //华为应用市场
        capabilities.setCapability("noReset", true);//实现app不是每次都安装
        capabilities.setCapability("dontStopAppOnRest",true);//不退出app
        capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, "60");
        driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    }
    @AfterSuite
    public void tearDown() throws Exception {

        driver.quit();

    }
}
